<template>
  <div id="Regulate" :class="{ smallFontSize: showEdition, mediumFontSize: !showEdition }">
    <div v-if="imagesList.length == 0" style="height: 78vh; text-align: center; padding-top: 20vh">
      <div style="margin-bottom: 10px">
        <img src="https://nfzjszlb.jst.zj.gov.cn/serverfile/zheliban/icon/DSF/50.png" />
      </div>
      <div>暂无数据</div>
    </div>
    <div v-else class="boxs">
      <div class="boxser" v-for="(item, index) in imagesList" :key="index" @click="toHref(item)">
        <div class="top">{{ item.projectName }}</div>
        <div class="bottom">
          <div class="left">
            <van-tag type="warning" size="large" style="fontsize: 14px">{{ item.zcfl }}</van-tag>
            <!-- <van-tag type="success" size="large" style="fontsize: 14px">{{ item.xssx || '暂无数据 ' }}</van-tag> -->
          </div>
          <div class="right"></div>
        </div>
        <div class="bottom1">
          <div class="left"><van-icon name="location" />{{ item.province }}{{ item.sss }} {{ item.ssx }}</div>
          <div class="right"><van-icon name="clock" />{{ item.sj }}</div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import { GetData, zhejiangJffwJfzs,selectListByIds } from '@/utils/api'
import { getENVIR } from '@/utils/getApporwx'
export default {
  data() {
    return {
      showEdition: true,
      value: '',
      showPicker: false,
      baseUrl1: window.g.BaseURL,
      baseUrl: window.g.OSSPriview1,
      columns: ['杭州', '宁波', '温州', '绍兴', '湖州', '嘉兴', '金华', '衢州'],
      imagesList: [],
    }
  },
  watch: {
    value() {
      this.getData()
    },
  },
  created() {
    //mock 20条数据
    this.showEdition = this.$store.state.Edition
    if (ZWJSBridge) {
      ZWJSBridge.setTitle({
        title: '建房知识',
      })
        .then((res) => {})
        .catch((err) => {})
    }
    this.getData()
  },
  methods: {
    onConfirm(value) {
      this.value = value
      this.showPicker = false
    },
    async toHref(item) {
      let url = ''
      if (item.fileId) {
        url = this.baseUrl1 + 'api/upload/oss/preview?fileId=' + item.fileId
      } else {
        this.$toast.fail('暂无附件！')
      }
      //跳转至view需要用户手动复制预览1
      //微信小程序需要端内打开
      if (window.sessionStorage.getItem('showBg2') == 'true') {
        this.$router.push({
          path: '/PDFJSViewer',
          query: {
            path: url,
          },
        })
      } else {
        //根据id获取
        let url1 = ''
        const res = await selectListByIds(item.fileId)
        url1 = this.baseUrl + res.data.data[0].path
        //iphone先这样处理
        if (ZWJSBridge) {
          ZWJSBridge.openLink({
            url: url1,
          })
            .then((res) => {})
            .catch((err) => {
              window.open(url1)
            })
        }
        //安卓问题待定
      }
    },
    getData: async function () {
      let parameter = {
        sss: window.localStorage.getItem('citycodeValue')||'杭州市',
      }
      const res = await zhejiangJffwJfzs(parameter)
      this.imagesList = []
      if (res.data.code == 200) {
        this.imagesList = res.data.data
      }
      console.log(this.imagesList)
    },
  },
}
</script>
<style lang="scss">
#Regulate {
  background: #eee;
  height: 100vh;
  overflow: auto;
  font-size: 17px;
  .boxs {
    width: 96vw;
    // position: relative;
    position: absolute;
    left: 50%;
    clear: both;
    transform: translateX(-50%);
  }
  .boxser {
    width: 96vw;
    border-radius: 6px;
    background: white;
    margin: 10px 0;
    padding: 10px;

    .top {
      font-weight: bold;
      color: #1a1a1a;
      font-size: 17px;
    }

    .bottom {
      display: flex;
      justify-content: space-between;
      height: 60px;
      .left {
        line-height: 60px;
      }

      .right {
      }
    }
    .bottom1 {
      display: flex;
      justify-content: space-between;
      .left {
      }
      .right {
      }
    }
  }
}
</style>
<style >
.van-cell {
  padding: 4px 14px !important;
}
</style>
